bitkeeper revision 1.689 (40118468UT1zIR80oFQpa0jMSoyUvA)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 23 Jan 2004 20:30:32 +0000 (20:30 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Fri, 23 Jan 2004 20:30:32 +0000 (20:30 +0000)
XenoUtil.py:
  Fix XenoUtil.py to import only what is necessary.

tools/xc/py/XenoUtil.py

index f17939a4a207fd3e20cbe1d0137329f74682c72f..d038e5d2049196882c80c718464cb4ea2f63da72 100644 (file)
@@ -1,4 +1,4 @@
-import string, re, os, sqlite, Xc, sys
+import string, re, os, sys
 
 ##### Module variables
 
@@ -16,6 +16,16 @@ VD_DB_FILE = "/var/spool/xen_vdisks.sqlite"
 """
 VBD_EXPERT_MODE = 0
 
+##### Module initialisation
+
+try:
+    # try to import sqlite (not everyone will have it installed)
+    import sqlite
+except ImportError:
+    # on failure, just catch the error, don't do anything
+    pass
+
+
 ##### Networking-related functions
 
 def get_current_ipaddr(dev='eth0'):
@@ -808,6 +818,8 @@ def vd_extents_validate(new_extents,new_writeable):
                    exceed VBD_EXPERT_MODE or -1 if it does (error)
     """
 
+    import Xc # this is only needed in this function
+
     xc = Xc.new()
 
     ##### Probe for explicitly created virtual disks and build a list